<template>
    <div>
      <Content style="width:90%">
        <Form :label-width="140">
          <FormItem label="上级频道" required>
            <Input v-model="dataBus.channelName" placeholder="无" disabled></Input>
          </FormItem>
          <FormItem label="频道名称" required>
            <Input v-model="dataForm.channelName" placeholder="请输入频道名称"></Input>
          </FormItem>
          <FormItem label="频道编码" required>
            <Input v-model="dataForm.channelCode" placeholder="请输入频道编码"></Input>
          </FormItem>
					<FormItem label="频道类型" required>
						<Select class="view-input" placeholder="请选择频道类型" v-model="dataForm.channelType">
							<Option v-for="(item,index) in seletions" :value="item.id" :key="index">{{item.name}}</Option>
						</Select>
					</FormItem>
          <FormItem label="排序" required>
            <InputNumber :min="1" v-model="dataForm.sortIndex" placeholder="请输入排序"></InputNumber>
          </FormItem>
          <FormItem label="外链地址">
            <Input v-model="dataForm.extLinks" placeholder="请输入外链地址"></Input>
          </FormItem>
          <FormItem label="是否启用">
            <RadioGroup v-model.number="dataForm.channelStatus">
              <Radio :label="1">
                <span>开启</span>
              </Radio>
              <Radio :label="0">
                <span>关闭</span>
              </Radio>
            </RadioGroup>
          </FormItem>
          <FormItem>
            <Button type="primary" @click="Submit">提交</Button>
          </FormItem>
        </Form>
      </Content>
    </div>
</template>
<script>
export default {
  name: "GroupCreate",
  props: {
		dataBus: Object,
    callbank: Function
  },
  data() {
    return {
			seletions: this.$dict.channelType.data,
      dataForm: {
        channelStatus: 1,
        sortIndex: 1
      }
    }
  },
  created() {
    
  },
  methods: {
    Submit() {
      if(this.dataBus.channelId) {
        this.dataForm.channelPid = this.dataBus.channelId
      }
      new this.$rest({
        gateway: 'agrobiz',
        service: "agrobiz-msg",
        url: "/v1.0/news/channel",
        data: {
          pojo: this.dataForm
        },
        action: (res) => {
          if (res.data.code === 20000) {
            this.$Message.success({
              content: '添加成功',
            })
            this.callbank()
          } else {
            this.$Message.error({
              content: res.data.msg
            })
          }
        },
      }).post()
    }
  }
}
</script>